From 371c7fa452b55bacb15fc43f313e3beae1a30c5c Mon Sep 17 00:00:00 2001 From: "Karl O. Pinc" Date: Sun, 15 Nov 2020 17:17:30 -0600 Subject: [PATCH] Move code out of __init__.py --- src/pgwui_logout/__init__.py | 25 +---------- src/pgwui_logout/pgwui_logout.py | 45 +++++++++++++++++++ ...{test___init__.py => test_pgwui_logout.py} | 8 ++-- 3 files changed, 50 insertions(+), 28 deletions(-) create mode 100644 src/pgwui_logout/pgwui_logout.py rename tests/{test___init__.py => test_pgwui_logout.py} (87%) diff --git a/src/pgwui_logout/__init__.py b/src/pgwui_logout/__init__.py index ef06bd3..f7a0909 100644 --- a/src/pgwui_logout/__init__.py +++ b/src/pgwui_logout/__init__.py @@ -19,27 +19,4 @@ # Karl O. Pinc -'''Provide a way to configure PGWUI. -''' - -PGWUI_COMPONENT = 'pgwui_logout' -DEFAULT_LOGOUT_ROUTE = '/logout' -DEFAULT_LOGOUT_MENU_LABEL = 'logout -- Logout from PGWUI programs' - - -def init_menu(config): - '''Add default menu information into settings when they are not present - ''' - settings = config.get_settings() - pgwui = settings.setdefault('pgwui', dict()) - pgwui.setdefault(PGWUI_COMPONENT, dict()) - pgwui[PGWUI_COMPONENT].setdefault( - 'menu_label', DEFAULT_LOGOUT_MENU_LABEL) - - -def includeme(config): - '''Pyramid configuration for PGWUI_Logout - ''' - init_menu(config) - config.add_route(PGWUI_COMPONENT, DEFAULT_LOGOUT_ROUTE) - config.scan() +from .pgwui_logout import includeme # noqa: F401 diff --git a/src/pgwui_logout/pgwui_logout.py b/src/pgwui_logout/pgwui_logout.py new file mode 100644 index 0000000..ef06bd3 --- /dev/null +++ b/src/pgwui_logout/pgwui_logout.py @@ -0,0 +1,45 @@ +# Copyright (C) 2018 The Meme Factory, Inc. http://www.meme.com/ + +# This file is part of PGWUI_Logout. +# +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU Affero General Public License +# as published by the Free Software Foundation, either version 3 of +# the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public +# License along with this program. If not, see +# . +# + +# Karl O. Pinc + +'''Provide a way to configure PGWUI. +''' + +PGWUI_COMPONENT = 'pgwui_logout' +DEFAULT_LOGOUT_ROUTE = '/logout' +DEFAULT_LOGOUT_MENU_LABEL = 'logout -- Logout from PGWUI programs' + + +def init_menu(config): + '''Add default menu information into settings when they are not present + ''' + settings = config.get_settings() + pgwui = settings.setdefault('pgwui', dict()) + pgwui.setdefault(PGWUI_COMPONENT, dict()) + pgwui[PGWUI_COMPONENT].setdefault( + 'menu_label', DEFAULT_LOGOUT_MENU_LABEL) + + +def includeme(config): + '''Pyramid configuration for PGWUI_Logout + ''' + init_menu(config) + config.add_route(PGWUI_COMPONENT, DEFAULT_LOGOUT_ROUTE) + config.scan() diff --git a/tests/test___init__.py b/tests/test_pgwui_logout.py similarity index 87% rename from tests/test___init__.py rename to tests/test_pgwui_logout.py index 66b9afb..381d378 100644 --- a/tests/test___init__.py +++ b/tests/test_pgwui_logout.py @@ -22,7 +22,7 @@ import pyramid.config from pyramid.threadlocal import get_current_request -import pgwui_logout.__init__ as pgwui_logout_init +import pgwui_logout.pgwui_logout as pgwui_logout # Activiate our pytest plugin @@ -44,11 +44,11 @@ def test_pgwui_upload_is_pgwui_component(pgwui_component_entry_point): def test_includeme_functional(pyramid_request_config): '''Sets a route for 'logout' ''' - pgwui_logout_init.includeme(pyramid_request_config) + pgwui_logout.includeme(pyramid_request_config) request = get_current_request() logout_path = request.route_path('pgwui_logout') - assert logout_path == pgwui_logout_init.DEFAULT_LOGOUT_ROUTE + assert logout_path == pgwui_logout.DEFAULT_LOGOUT_ROUTE # Integration tests @@ -57,4 +57,4 @@ def test_includeme_integration(): '''Does not blow up ''' config = pyramid.config.Configurator() - pgwui_logout_init.includeme(config) + pgwui_logout.includeme(config) -- 2.34.1